package com.itheima.common;

import com.itheima.domain.User;
import com.itheima.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;

/**
 * @Author itheima
 * @Date 2022/5/3 10:44
 */
@WebFilter("/*")
public class MyFilter implements Filter {
    @Autowired
    UserService userService;

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
        System.out.println("MyFilter.doFilter开始");
        User user = userService.queryUser(12L);
        System.out.println("user = " + user);
        chain.doFilter(request, response);
        System.out.println("MyFilter.doFilter结束");
    }
}
